package com.jason.campusinn.view;

import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.yuandian.wanna.R;

/**
 * Created by yuandian on 2015/5/20.
 */
public class CommonTipDialog extends Dialog{
    private Context mContext;
    private TextView mTvContent;
    private Button mBtnCancel;
    private Button mBtnEnter;
    private TextView mTvTitle;

    public CommonTipDialog(Context context) {
        super(context, R.style.dialog_style_float);
        this.mContext = context;
        setContentView(R.layout.dialog_common_tip);
        setCancelable(true);
        setCanceledOnTouchOutside(true);
        initView();
    }

    private void initView() {
        mTvTitle = (TextView) findViewById(R.id.dialog_common__tv_title);
        mTvContent = (TextView) findViewById(R.id.dialog_common__tv_content);
        mBtnCancel = (Button) findViewById(R.id.dialog_common_btn_cancel);
        mBtnEnter = (Button) findViewById(R.id.dialog_common_btn_enter);
        mBtnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public CommonTipDialog setTitle(String title){
        mTvTitle.setText(title);
        return this;
    }

    public CommonTipDialog setContent(String content){
        mTvContent.setText(content);
        return this;
    }

    public CommonTipDialog setEnterBtn(String text,View.OnClickListener clickListner){
        if (!TextUtils.isEmpty(text)) {
            mBtnEnter.setText(text);
        }
        mBtnEnter.setOnClickListener(clickListner);
        return this;
    }

    public CommonTipDialog setCancelBtn(String text,View.OnClickListener clickListner){
        if (!TextUtils.isEmpty(text)) {
            mBtnCancel.setText(text);
        }
        mBtnCancel.setOnClickListener(clickListner);
        return this;
    }



}
